<template>
   <div class="content">
      <div class="title">{{data.title}}</div>
      <div class="item" v-for="(item,index) in data.data" :key="item.id" >
          <template v-if="index<dataLen">
        <span>{{item.title}}</span>
        <el-button type="primary" @click="showDetail(item.id,item.type)">查看详情</el-button>
        </template>
      </div>
      <div class="pagination" v-if="isShowPagination">
        <el-pagination
        prev-text="上一页"
        next-text="下一页"

            background
            layout="prev, pager, next"
            @prev-click="currentChange"
            @next-click="currentChange"
            @current-change="currentChange"
            :current-page="currentPage"
            :total="data.totalPages">
            </el-pagination>
        </div>
    </div>
</template>
<script>
export default {
    props:{
        data:{
            type:Object|Array,
            default:()=>{
                return {}
            }
        },
        currentPage:{
            type:Number,
            default:1,
        },
        isShowPagination:{
            type:Boolean,
            default:true,
        }
    },
    data(){
        return {
            dataLen:{}
        }
    },
    created(){
        if(isShowPagination){
            this.dataLen = data.data.length;
        }else{
            if(data.data.length >10) {
              this.dataLen = 10; 
            }else{
              this.dataLen = data.data.length;
            }
        }
    },
    methods:{
        currentChange(val){
            this.$emit('current-change',val);
        },
        showDetail(id,type){
            console.log(type);
            this.$emit('show-detail',id,type)
           
        }
    }
}
</script>
